﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kevin.Framework.Data.OrmMapping;
using Kevin.Framework.Validation;

namespace JOIN.Rights.Model
{
    [Serializable]
    [TableMapping("TU_Admin")]
    public class AdminInfo:EntityBase
    {
        #region Constructor

        public AdminInfo()
            : this("")
        { }
        public AdminInfo(string connectionKey)
            : base(connectionKey)
        { }

        #endregion


        private int _userid;
        /// <summary>
        /// 用户ID
        /// </summary>		
        [FieldMapping("UserID", IsIdentity = true, PrimaryKey = true)]
        [AutoIncrement()]
        public int UserID
        {
            get
            {
                return _userid;
            }
            set
            {
                if (_userid != value)
                {
                    //base.OnPropertyChanged("UserID", _userid, value);
                    _userid = value;
                }
            }
        }

        private string _userno;
        /// <summary>
        /// 用户帐号
        /// </summary>		
        [FieldMapping("UserNO")]
        [NotNullValidator(MessageTemplate = "用户帐号不能为空")]
        public string UserNO
        {
            get
            {
                return _userno;
            }
            set
            {
                if (_userno != value)
                {
                    base.OnPropertyChanged("UserNO", _userno, value);
                    _userno = value;
                }
            }
        }

        private string _userpwd;
        /// <summary>
        /// 用户密码
        /// </summary>		
        [FieldMapping("UserPwd")]
        [NotNullValidator(MessageTemplate = "用户密码不能为空")]
        public string UserPwd
        {
            get
            {
                return _userpwd;
            }
            set
            {
                if (_userpwd != value)
                {
                    //string encryptPwd = value.ToMD5String();
                    base.OnPropertyChanged("UserPwd", _userpwd, value);
                    _userpwd = value;
                }
            }
        }

        private string _username;
        /// <summary>
        /// 用户姓名
        /// </summary>		
        [FieldMapping("UserName")]
        [NotNullValidator(MessageTemplate = "用户姓名不能为空")]
        public string UserName
        {
            get
            {
                return _username;
            }
            set
            {
                if (_username != value)
                {
                    base.OnPropertyChanged("UserName", _username, value);
                    _username = value;
                }
            }
        }

        private UserSex _usersex;
        /// <summary>
        /// 性别
        /// </summary>		
        [FieldMapping("UserSex")]
        public UserSex UserSex
        {
            get
            {
                return _usersex;
            }
            set
            {
                if (_usersex != value)
                {
                    base.OnPropertyChanged("UserSex", _usersex, value);
                    _usersex = value;
                }
            }
        }

        private string _userphone;
        /// <summary>
        /// 联系电话
        /// </summary>		
        [FieldMapping("UserPhone")]
        public string UserPhone
        {
            get
            {
                return _userphone;
            }
            set
            {
                if (_userphone != value)
                {
                    base.OnPropertyChanged("UserPhone", _userphone, value);
                    _userphone = value;
                }
            }
        }

        private string _useraddress;
        /// <summary>
        /// 住址
        /// </summary>		
        [FieldMapping("UserAddress")]
        public string UserAddress
        {
            get
            {
                return _useraddress;
            }
            set
            {
                if (_useraddress != value)
                {
                    base.OnPropertyChanged("UserAddress", _useraddress, value);
                    _useraddress = value;
                }
            }
        }

        private string _useremail;
        /// <summary>
        /// 电子邮件
        /// </summary>		
        [FieldMapping("UserEmail")]
        public string UserEmail
        {
            get
            {
                return _useremail;
            }
            set
            {
                if (_useremail != value)
                {
                    base.OnPropertyChanged("UserEmail", _useremail, value);
                    _useremail = value;
                }
            }
        }

        private UserState _userstate;
        /// <summary>
        /// 帐号状态(0:正常使用,1:锁定)
        /// </summary>		
        [FieldMapping("UserState")]
        public UserState UserState
        {
            get
            {
                return _userstate;
            }
            set
            {
                if (_userstate != value)
                {
                    base.OnPropertyChanged("UserState", _userstate, value);
                    _userstate = value;
                }
            }
        }    
    }
}
